-- Leviathan (c) v.v.balashoff
-- based on Snowflakes effect for Löve
-- https://github.com/Cowa/love-snowflakes-effect
-- Copyright (c) 2016 Brice Thomas
-- The MIT License (MIT)
local Class = require('leviathan/Class')

local SnowComponent = Class:derive('SnowComponent')

function SnowComponent:new(number, x, y, w, h, upTime)
    self.id = 'SnowComponent'
    self.typeId = 'Renderable'
    self.drawable = true
    self.enabled = true

    self.number = number or 1000
    self.x = x or 0
    self.y = y or 0
    self.w = w or love.graphics.getWidth()
    self.h = h or love.graphics.getHeight()
    -- rounding values
    self.w = math.floor(self.w)
    self.h = math.floor(self.h)
    self.upTime = upTime or 0.018
    self.buffer = love.graphics.newCanvas(self.w, self.h)
    self.time = love.timer.getTime()
    -- creating particles
    self.particles = {}
    for i = 1, self.number do
        table.insert(self.particles, {
            x = math.random() * self.w,
            y = math.random() * self.h,
            r = math.random() * 5 + 1,
            d = math.random() * self.number
        })
    end
    self.angle = 0
end

return SnowComponent
